﻿using System;
using System.Linq;
using System.Web.UI.WebControls;
using MONTRASEC_test.Classes;
using System.Data.Linq;


namespace MONTRASEC_test.Controls
{
  public partial class wucDVB1Events : System.Web.UI.UserControl
  {
    //public DetailsViewRowCollection Rows
    //{
    //  get { return this.dvB1Events.Rows; }
    //}

    public Label LDVMode
    {
      get { return lbDVMode; }
      set { lbDVMode = value; }
    }

    public BulletedList BPleaseFillOtherTemplates
    {
      get { return bPleaseFillOtherTemplates; }
      set { bPleaseFillOtherTemplates = value; }
    }

    public Label LbTotalRecords
    {
      get { return lbTotalRecords; }
      set { lbTotalRecords = value; }
    }

    public DetailsView dv
    {
      get { return dvB1Events; }
      set { dvB1Events = value; }
    }


    protected void Page_Load(object sender, EventArgs e)
    {

    }

    protected void dvB1Events_ItemInserting(object sender, DetailsViewInsertEventArgs e)
    {
      e.Values["B_1_EVENTS_RECRUITMENT_PERIODOFTHEEVENT"] = UtilHelper.getDateTime(e.Values["B_1_EVENTS_RECRUITMENT_PERIODOFTHEEVENT"]);

      e.Values["B_1_EVENTS_DIGEST"] = UtilHelper.getHash(e.Values["B_1_EVENTS_ACTIVITIES_RECRUITMENT"]);

      e.Values["B_1_EVENTS_DIGEST_NFP"] = UtilHelper.getHash(UtilHelper.getHash(e.Values["B_1_EVENTS_DIGEST"]));

      e.Values["B_1_EVENTS_A_NEWENTRY_ID"] = Session["CurrentANewEntryID"];
    }

    protected void dvB1Events_ItemUpdating(object sender, DetailsViewUpdateEventArgs e)
    {
      e.NewValues["B_1_EVENTS_RECRUITMENT_PERIODOFTHEEVENT"] = UtilHelper.getDateTime(e.NewValues["B_1_EVENTS_RECRUITMENT_PERIODOFTHEEVENT"]);

      e.NewValues["B_1_EVENTS_DIGEST"] = UtilHelper.getHash(e.NewValues["B_1_EVENTS_ACTIVITIES_RECRUITMENT"]);

      e.NewValues["B_1_EVENTS_DIGEST_NFP"] = UtilHelper.getHash(UtilHelper.getHash(e.NewValues["B_1_EVENTS_DIGEST"]));

      e.NewValues["B_1_EVENTS_A_NEWENTRY_ID"] = Session["CurrentANewEntryID"];
    }

    protected void detailsView_ModeChanged(object sender, EventArgs e)
    {
      onDetailsView_ModeChanged(e);
    }
    // the delegate; a delegate is a reference type used to encapsulate a method with a specific signature and return type.* You can encapsulate any matching method in that delegate.
    public delegate void detailsView_ModeChangedHandler(object sender, EventArgs e);

    // an instance of the delegate
    public event detailsView_ModeChangedHandler DetailsView_ModeChanged;

    protected virtual void onDetailsView_ModeChanged(EventArgs e)
    {
      if (DetailsView_ModeChanged != null)
      {
        DetailsView_ModeChanged(this, e);
      }
    }

    protected void detailsView_ItemDeleted(object sender, DetailsViewDeletedEventArgs e)
    {
      onDetailsView_ItemDeleted(e);
    }
    // the delegate; a delegate is a reference type used to encapsulate a method with a specific signature and return type.* You can encapsulate any matching method in that delegate.
    public delegate void detailsView_ItemDeletedHandler(object sender, EventArgs e);

    // an instance of the delegate
    public event detailsView_ItemDeletedHandler DetailsView_ItemDeleted;

    protected virtual void onDetailsView_ItemDeleted(EventArgs e)
    {
      if (DetailsView_ItemDeleted != null)
      {
        DetailsView_ItemDeleted(this, e);
      }
    }

    protected void detailsView_ItemInserted(object sender, DetailsViewInsertedEventArgs e)
    {
      onDetailsView_ItemInserted(e);
    }
    // the delegate; a delegate is a reference type used to encapsulate a method with a specific signature and return type.* You can encapsulate any matching method in that delegate.
    public delegate void detailsView_ItemInsertedHandler(object sender, EventArgs e);

    // an instance of the delegate
    public event detailsView_ItemInsertedHandler DetailsView_ItemInserted;

    protected virtual void onDetailsView_ItemInserted(EventArgs e)
    {
      if (DetailsView_ItemInserted != null)
      {
        DetailsView_ItemInserted(this, e);
      }
    }

    protected void detailsView_ItemUpdated(object sender, DetailsViewUpdatedEventArgs e)
    {

      onDetailsView_ItemUpdated(e);
    }
    // the delegate; a delegate is a reference type used to encapsulate a method with a specific signature and return type.* You can encapsulate any matching method in that delegate.
    public delegate void detailsView_ItemUpdatedHandler(object sender, EventArgs e);

    // an instance of the delegate
    public event detailsView_ItemUpdatedHandler DetailsView_ItemUpdated;

    protected virtual void onDetailsView_ItemUpdated(EventArgs e)
    {
      if (DetailsView_ItemUpdated != null)
      {
        DetailsView_ItemUpdated(this, e);
      }
    }

    protected void replicateARow(object sender, DetailsViewCommandEventArgs e)
    {
      String myMessage = ""; //message listing the id's that have been updated
      DetailsView dv = (DetailsView)sender;
      int index = int.Parse(e.CommandArgument.ToString());

      String id = (dv.DataKey["ID"]).ToString();

      MONTRASEC_test.Classes.A_NEWENTRY_DataContext dataContext = new MONTRASEC_test.Classes.A_NEWENTRY_DataContext();

      using (System.Transactions.TransactionScope scope =
new System.Transactions.TransactionScope())
      {

      var newEntryToCopy =
          from b in dataContext.GetTable<A_NEWENTRY_>()
          where b.ID == long.Parse(id)
          select b;



      foreach (A_NEWENTRY_ c in newEntryToCopy)
      {
        var recordsToWhichToReplicate =
          from listOfRecordsToReplicate in dataContext.GetTable<A_NEWENTRY_>()
          where listOfRecordsToReplicate.A_NEWENTRY_NEWENTRY_POLICE_CUSTOMSFILEIDENTIF.Equals(c.A_NEWENTRY_NEWENTRY_POLICE_CUSTOMSFILEIDENTIF)
          && listOfRecordsToReplicate.A_NEWENTRY_NEWENTRY_PUBLICPROSECUTORSFILEIDEN.Equals(c.A_NEWENTRY_NEWENTRY_PUBLICPROSECUTORSFILEIDEN)
          && listOfRecordsToReplicate.A_NEWENTRY_NEWENTRY_COURTSFILEIDENTIFICATIONN.Equals(c.A_NEWENTRY_NEWENTRY_COURTSFILEIDENTIFICATIONN)
          && listOfRecordsToReplicate.ID != c.ID
          select listOfRecordsToReplicate;

        foreach (A_NEWENTRY_ recordToWhichToReplicate in recordsToWhichToReplicate)
        {

          recordToWhichToReplicate.B_1_EVENTS_DIGEST = c.B_1_EVENTS_DIGEST;
          recordToWhichToReplicate.B_1_EVENTS_DIGEST_NFP = c.B_1_EVENTS_DIGEST_NFP;
          recordToWhichToReplicate.B_1_EVENTS_ACTIVITIES_RECRUITMENT = c.B_1_EVENTS_ACTIVITIES_RECRUITMENT;
          recordToWhichToReplicate.B_1_EVENTS_ACTIVITIES_TRANSPORTATION = c.B_1_EVENTS_ACTIVITIES_TRANSPORTATION;
          recordToWhichToReplicate.B_1_EVENTS_ACTIVITIES_TRANSFER = c.B_1_EVENTS_ACTIVITIES_TRANSFER;

          recordToWhichToReplicate.B_1_EVENTS_ACTIVITIES_HARBOURING = c.B_1_EVENTS_ACTIVITIES_HARBOURING;
          recordToWhichToReplicate.B_1_EVENTS_ACTIVITIES_RECEIPTOFPERSONS = c.B_1_EVENTS_ACTIVITIES_RECEIPTOFPERSONS;
          recordToWhichToReplicate.B_1_EVENTS_RECRUITMENT_PERIODOFTHEEVENT = c.B_1_EVENTS_RECRUITMENT_PERIODOFTHEEVENT;
          recordToWhichToReplicate.B_1_EVENTS_MANNEROFINITIATIONOFCONTA_PERSONALCONTACT = c.B_1_EVENTS_MANNEROFINITIATIONOFCONTA_PERSONALCONTACT;
          recordToWhichToReplicate.B_1_EVENTS_MANNEROFINITIATIONOFCONTA_NEWSPAPERADVERTISEMENT = c.B_1_EVENTS_MANNEROFINITIATIONOFCONTA_NEWSPAPERADVERTISEMENT;
          recordToWhichToReplicate.B_1_EVENTS_MANNEROFINITIATIONOFCONTA_RADIOADVERTISEMENT = c.B_1_EVENTS_MANNEROFINITIATIONOFCONTA_RADIOADVERTISEMENT;
          recordToWhichToReplicate.B_1_EVENTS_MANNEROFINITIATIONOFCONTA_INTERNETADVERTISEMENT = c.B_1_EVENTS_MANNEROFINITIATIONOFCONTA_INTERNETADVERTISEMENT;
          recordToWhichToReplicate.B_1_EVENTS_MANNEROFINITIATIONOFCONTA_TELEVISIONADVERTISEMENT = c.B_1_EVENTS_MANNEROFINITIATIONOFCONTA_TELEVISIONADVERTISEMENT;
          recordToWhichToReplicate.B_1_EVENTS_MANNEROFINITIATIONOFCONTA_SOLDBYFAMILYMEMBER = c.B_1_EVENTS_MANNEROFINITIATIONOFCONTA_SOLDBYFAMILYMEMBER;
          recordToWhichToReplicate.B_1_EVENTS_MANNEROFINITIATIONOFCONTA_KIDNAPPED = c.B_1_EVENTS_MANNEROFINITIATIONOFCONTA_KIDNAPPED;
          recordToWhichToReplicate.B_1_EVENTS_MANNEROFINITIATIONOFCONTA_OTHERALLFIELDSBUTTHESEALR = c.B_1_EVENTS_MANNEROFINITIATIONOFCONTA_OTHERALLFIELDSBUTTHESEALR;
          recordToWhichToReplicate.B_1_EVENTS_DURATIONOFTRANSPORTATION_DURATIONOFTRANSPORTATION = c.B_1_EVENTS_DURATIONOFTRANSPORTATION_DURATIONOFTRANSPORTATION;
          recordToWhichToReplicate.B_1_EVENTS_MEANSOFTRANSPORTUSED_CAR = c.B_1_EVENTS_MEANSOFTRANSPORTUSED_CAR;
          recordToWhichToReplicate.B_1_EVENTS_MEANSOFTRANSPORTUSED_BUS = c.B_1_EVENTS_MEANSOFTRANSPORTUSED_BUS;
          recordToWhichToReplicate.B_1_EVENTS_MEANSOFTRANSPORTUSED_TRAIN = c.B_1_EVENTS_MEANSOFTRANSPORTUSED_TRAIN;
          recordToWhichToReplicate.B_1_EVENTS_MEANSOFTRANSPORTUSED_BOAT = c.B_1_EVENTS_MEANSOFTRANSPORTUSED_BOAT;
          recordToWhichToReplicate.B_1_EVENTS_MEANSOFTRANSPORTUSED_AIRPLANE = c.B_1_EVENTS_MEANSOFTRANSPORTUSED_AIRPLANE;
          recordToWhichToReplicate.B_1_EVENTS_MEANSOFTRANSPORTUSED_TRUCK_CONTAINER = c.B_1_EVENTS_MEANSOFTRANSPORTUSED_TRUCK_CONTAINER;
          recordToWhichToReplicate.B_1_EVENTS_MEANSOFTRANSPORTUSED_BYFOOT = c.B_1_EVENTS_MEANSOFTRANSPORTUSED_BYFOOT;
          recordToWhichToReplicate.B_1_EVENTS_NATIONSCROSSEDDURINGTHETR_COUNTRYOFORIGIN = c.B_1_EVENTS_NATIONSCROSSEDDURINGTHETR_COUNTRYOFORIGIN;
          recordToWhichToReplicate.B_1_EVENTS_NATIONSCROSSEDDURINGTHETR_COUNTRYSTRANSITED = c.B_1_EVENTS_NATIONSCROSSEDDURINGTHETR_COUNTRYSTRANSITED;
          recordToWhichToReplicate.B_1_EVENTS_NATIONSCROSSEDDURINGTHETR_COUNTRYOFDESTINATION = c.B_1_EVENTS_NATIONSCROSSEDDURINGTHETR_COUNTRYOFDESTINATION;
          recordToWhichToReplicate.B_1_EVENTS_BORDERSCROSSED_GREENBORDER = c.B_1_EVENTS_BORDERSCROSSED_GREENBORDER;
          recordToWhichToReplicate.B_1_EVENTS_BORDERSCROSSED_BLUEBORDER = c.B_1_EVENTS_BORDERSCROSSED_BLUEBORDER;
          recordToWhichToReplicate.B_1_EVENTS_BORDERSCROSSED_UNKNOWN = c.B_1_EVENTS_BORDERSCROSSED_UNKNOWN;
          recordToWhichToReplicate.B_1_EVENTS_EXPLOITATIONINTHETRANSPOR_EXPLOITATIONDURINGTRANSPO = c.B_1_EVENTS_EXPLOITATIONINTHETRANSPOR_EXPLOITATIONDURINGTRANSPO;
          recordToWhichToReplicate.B_1_EVENTS_EXPLOITATIONINTHETRANSPOR_TYPEOFEXPLOITATION = c.B_1_EVENTS_EXPLOITATIONINTHETRANSPOR_TYPEOFEXPLOITATION;
          recordToWhichToReplicate.B_1_EVENTS_PLACESOFHARBOURING_APARTMENT_PRIVATEDWELLING = c.B_1_EVENTS_PLACESOFHARBOURING_APARTMENT_PRIVATEDWELLING;
          recordToWhichToReplicate.B_1_EVENTS_PLACESOFHARBOURING_HOTEL_MOTEL = c.B_1_EVENTS_PLACESOFHARBOURING_HOTEL_MOTEL;
          recordToWhichToReplicate.B_1_EVENTS_PLACESOFHARBOURING_CAMPINGAREA = c.B_1_EVENTS_PLACESOFHARBOURING_CAMPINGAREA;
          recordToWhichToReplicate.B_1_EVENTS_PLACESOFHARBOURING_PLACEOFEXPLOITATION = c.B_1_EVENTS_PLACESOFHARBOURING_PLACEOFEXPLOITATION;
          recordToWhichToReplicate.B_1_EVENTS_DURATIONOFEXPLOITATION_DURATIONOFEXPLOITATION = c.B_1_EVENTS_DURATIONOFEXPLOITATION_DURATIONOFEXPLOITATION;
          recordToWhichToReplicate.B_1_EVENTS_SEXUALEXPLOITATION_SEXUALEXPLOITATION = c.B_1_EVENTS_SEXUALEXPLOITATION_SEXUALEXPLOITATION;
          recordToWhichToReplicate.B_1_EVENTS_TYPEOFSEXUALEXPLOITATION_PROSTITUTION = c.B_1_EVENTS_TYPEOFSEXUALEXPLOITATION_PROSTITUTION;
          recordToWhichToReplicate.B_1_EVENTS_TYPEOFSEXUALEXPLOITATION_CHILDPROSTITUTION = c.B_1_EVENTS_TYPEOFSEXUALEXPLOITATION_CHILDPROSTITUTION;
          recordToWhichToReplicate.B_1_EVENTS_TYPEOFSEXUALEXPLOITATION_PORNOGRAPHY = c.B_1_EVENTS_TYPEOFSEXUALEXPLOITATION_PORNOGRAPHY;
          recordToWhichToReplicate.B_1_EVENTS_TYPEOFSEXUALEXPLOITATION_CHILDPORNOGRAPHY = c.B_1_EVENTS_TYPEOFSEXUALEXPLOITATION_CHILDPORNOGRAPHY;
          recordToWhichToReplicate.B_1_EVENTS_TYPEOFSEXUALEXPLOITATION_SEXTOURISM = c.B_1_EVENTS_TYPEOFSEXUALEXPLOITATION_SEXTOURISM;
          recordToWhichToReplicate.B_1_EVENTS_TYPEOFSEXUALEXPLOITATION_OTHER = c.B_1_EVENTS_TYPEOFSEXUALEXPLOITATION_OTHER;
          recordToWhichToReplicate.B_1_EVENTS_PLACEOFSEXUALEXPLOITATION_OUTDOOR = c.B_1_EVENTS_PLACEOFSEXUALEXPLOITATION_OUTDOOR;
          recordToWhichToReplicate.B_1_EVENTS_PLACEOFSEXUALEXPLOITATION_INDOOR_APARTMENT = c.B_1_EVENTS_PLACEOFSEXUALEXPLOITATION_INDOOR_APARTMENT;
          recordToWhichToReplicate.B_1_EVENTS_PLACEOFSEXUALEXPLOITATION_INDOOR_BROTHEL = c.B_1_EVENTS_PLACEOFSEXUALEXPLOITATION_INDOOR_BROTHEL;
          recordToWhichToReplicate.B_1_EVENTS_PLACEOFSEXUALEXPLOITATION_INDOOR_SAUNA = c.B_1_EVENTS_PLACEOFSEXUALEXPLOITATION_INDOOR_SAUNA;
          recordToWhichToReplicate.B_1_EVENTS_PLACEOFSEXUALEXPLOITATION_INDOOR_CLUB = c.B_1_EVENTS_PLACEOFSEXUALEXPLOITATION_INDOOR_CLUB;






          recordToWhichToReplicate.B_1_EVENTS_PLACEOFSEXUALEXPLOITATION_INDOOR_HOTEL_MOTEL = c.B_1_EVENTS_PLACEOFSEXUALEXPLOITATION_INDOOR_HOTEL_MOTEL;
          recordToWhichToReplicate.B_1_EVENTS_PLACEOFSEXUALEXPLOITATION_INDOOR_PUB_BAR = c.B_1_EVENTS_PLACEOFSEXUALEXPLOITATION_INDOOR_PUB_BAR;
          recordToWhichToReplicate.B_1_EVENTS_PLACEOFSEXUALEXPLOITATION_CALLGIRLS_ESCORTSERVICE = c.B_1_EVENTS_PLACEOFSEXUALEXPLOITATION_CALLGIRLS_ESCORTSERVICE;
          recordToWhichToReplicate.B_1_EVENTS_PLACEOFSEXUALEXPLOITATION_OTHER = c.B_1_EVENTS_PLACEOFSEXUALEXPLOITATION_OTHER;
          recordToWhichToReplicate.B_1_EVENTS_LABOUREXPLOITATION_LABOUREXPLOITATION = c.B_1_EVENTS_LABOUREXPLOITATION_LABOUREXPLOITATION;
          recordToWhichToReplicate.B_1_EVENTS_TYPEOFLABOUREXPLOITATION_SLAVERY = c.B_1_EVENTS_TYPEOFLABOUREXPLOITATION_SLAVERY;
          recordToWhichToReplicate.B_1_EVENTS_TYPEOFLABOUREXPLOITATION_COMPULSORYWORK = c.B_1_EVENTS_TYPEOFLABOUREXPLOITATION_COMPULSORYWORK;
          recordToWhichToReplicate.B_1_EVENTS_TYPEOFLABOUREXPLOITATION_BONDEDLABOUR = c.B_1_EVENTS_TYPEOFLABOUREXPLOITATION_BONDEDLABOUR;
          recordToWhichToReplicate.B_1_EVENTS_SECTOROFLABOUREXPLOITATIO_AGRICULTURE = c.B_1_EVENTS_SECTOROFLABOUREXPLOITATIO_AGRICULTURE;
          recordToWhichToReplicate.B_1_EVENTS_SECTOROFLABOUREXPLOITATIO_INDUSTRY = c.B_1_EVENTS_SECTOROFLABOUREXPLOITATIO_INDUSTRY;
          recordToWhichToReplicate.B_1_EVENTS_SECTOROFLABOUREXPLOITATIO_COMMERCE = c.B_1_EVENTS_SECTOROFLABOUREXPLOITATIO_COMMERCE;
          recordToWhichToReplicate.B_1_EVENTS_SECTOROFLABOUREXPLOITATIO_SERVICES = c.B_1_EVENTS_SECTOROFLABOUREXPLOITATIO_SERVICES;
          recordToWhichToReplicate.B_1_EVENTS_SECTOROFLABOUREXPLOITATIO_PRIVATE = c.B_1_EVENTS_SECTOROFLABOUREXPLOITATIO_PRIVATE;
          recordToWhichToReplicate.B_1_EVENTS_SECTOROFLABOUREXPLOITATIO_LEISURE = c.B_1_EVENTS_SECTOROFLABOUREXPLOITATIO_LEISURE;
          recordToWhichToReplicate.B_1_EVENTS_OTHERFORMSOFEXPLOITATION_OTHERFORMSOFEXPLOITATION = c.B_1_EVENTS_OTHERFORMSOFEXPLOITATION_OTHERFORMSOFEXPLOITATION;
          recordToWhichToReplicate.B_1_EVENTS_TYPEOFOTHEREXPLOITATION_BEGGING = c.B_1_EVENTS_TYPEOFOTHEREXPLOITATION_BEGGING;
          recordToWhichToReplicate.B_1_EVENTS_TYPEOFOTHEREXPLOITATION_LOW_LEVELCRIMINALITY = c.B_1_EVENTS_TYPEOFOTHEREXPLOITATION_LOW_LEVELCRIMINALITY;
          recordToWhichToReplicate.B_1_EVENTS_TYPEOFOTHEREXPLOITATION_STREET_SELLING = c.B_1_EVENTS_TYPEOFOTHEREXPLOITATION_STREET_SELLING;
          recordToWhichToReplicate.B_1_EVENTS_TYPEOFOTHEREXPLOITATION_REMOVALOFORGANS = c.B_1_EVENTS_TYPEOFOTHEREXPLOITATION_REMOVALOFORGANS;
          recordToWhichToReplicate.B_1_EVENTS_TYPEOFOTHEREXPLOITATION_MILITARYSERVICE = c.B_1_EVENTS_TYPEOFOTHEREXPLOITATION_MILITARYSERVICE;
          recordToWhichToReplicate.B_1_EVENTS_TYPEOFOTHEREXPLOITATION_ILLEGALADOPTION = c.B_1_EVENTS_TYPEOFOTHEREXPLOITATION_ILLEGALADOPTION;
          recordToWhichToReplicate.B_1_EVENTS_TYPEOFOTHEREXPLOITATION_OTHERALLFIELDSBUTTHESEALR = c.B_1_EVENTS_TYPEOFOTHEREXPLOITATION_OTHERALLFIELDSBUTTHESEALR;
          recordToWhichToReplicate.B_1_EVENTS_ACTCTXTRAFFICKING_RAPE = c.B_1_EVENTS_ACTCTXTRAFFICKING_RAPE;
          recordToWhichToReplicate.B_1_EVENTS_ACTCTXTRAFFICKING_FORGERY = c.B_1_EVENTS_ACTCTXTRAFFICKING_FORGERY;
          recordToWhichToReplicate.B_1_EVENTS_ACTCTXTRAFFICKING_FRAUD = c.B_1_EVENTS_ACTCTXTRAFFICKING_FRAUD;
          recordToWhichToReplicate.B_1_EVENTS_ACTCTXTRAFFICKING_COUNTERFEITING = c.B_1_EVENTS_ACTCTXTRAFFICKING_COUNTERFEITING;
          recordToWhichToReplicate.B_1_EVENTS_ACTCTXTRAFFICKING_UNDECLAREDLABOUR = c.B_1_EVENTS_ACTCTXTRAFFICKING_UNDECLAREDLABOUR;
          recordToWhichToReplicate.B_1_EVENTS_ACTCTXTRAFFICKING_KEEPINGABROTHEL = c.B_1_EVENTS_ACTCTXTRAFFICKING_KEEPINGABROTHEL;
          recordToWhichToReplicate.B_1_EVENTS_ACTCTXTRAFFICKING_BRIBERYOFPUBLICOFFICIALS = c.B_1_EVENTS_ACTCTXTRAFFICKING_BRIBERYOFPUBLICOFFICIALS;
          recordToWhichToReplicate.B_1_EVENTS_ACTCTXTRAFFICKING_ILLEGALIMMIGRATION = c.B_1_EVENTS_ACTCTXTRAFFICKING_ILLEGALIMMIGRATION;
          recordToWhichToReplicate.B_1_EVENTS_ACTCTXTRAFFICKING_CHILDPORNOGRAPHY = c.B_1_EVENTS_ACTCTXTRAFFICKING_CHILDPORNOGRAPHY;
          recordToWhichToReplicate.B_1_EVENTS_ACTCTXTRAFFICKING_SEXUALASSAULT = c.B_1_EVENTS_ACTCTXTRAFFICKING_SEXUALASSAULT;
          recordToWhichToReplicate.B_1_EVENTS_ACTCTXTRAFFICKING_SEXTOURISM = c.B_1_EVENTS_ACTCTXTRAFFICKING_SEXTOURISM;
          recordToWhichToReplicate.B_1_EVENTS_ACTCTXTRAFFICKING_OTHER = c.B_1_EVENTS_ACTCTXTRAFFICKING_OTHER;
          recordToWhichToReplicate.B_1_EVENTS_MODUSOPERANDI_MISUSEOFPOSITIONOROFAPOSI = c.B_1_EVENTS_MODUSOPERANDI_MISUSEOFPOSITIONOROFAPOSI;
          recordToWhichToReplicate.B_1_EVENTS_MODUSOPERANDI_ADMINISTRATIONOFDRUG_MEDI = c.B_1_EVENTS_MODUSOPERANDI_ADMINISTRATIONOFDRUG_MEDI;
          recordToWhichToReplicate.B_1_EVENTS_MODUSOPERANDI_ABDUCTION = c.B_1_EVENTS_MODUSOPERANDI_ABDUCTION;
          recordToWhichToReplicate.B_1_EVENTS_MODUSOPERANDI_RESTRICTIONSONFREEDOMOFMO = c.B_1_EVENTS_MODUSOPERANDI_RESTRICTIONSONFREEDOMOFMO;
          recordToWhichToReplicate.B_1_EVENTS_MODUSOPERANDI_TAKESDOCUMENTSAWAYFROMVIC = c.B_1_EVENTS_MODUSOPERANDI_TAKESDOCUMENTSAWAYFROMVIC;
          recordToWhichToReplicate.B_1_EVENTS_MODUSOPERANDI_BYMEANSOFDECEPTION = c.B_1_EVENTS_MODUSOPERANDI_BYMEANSOFDECEPTION;
          recordToWhichToReplicate.B_1_EVENTS_MODUSOPERANDI_PROMISEOFMARRIAGE_ENGAGEM = c.B_1_EVENTS_MODUSOPERANDI_PROMISEOFMARRIAGE_ENGAGEM;
          recordToWhichToReplicate.B_1_EVENTS_MODUSOPERANDI_BYMEANSOFFORCE_THREATOROT = c.B_1_EVENTS_MODUSOPERANDI_BYMEANSOFFORCE_THREATOROT;
          recordToWhichToReplicate.B_1_EVENTS_MODUSOPERANDI_THROUGHDEBTBONDAGE = c.B_1_EVENTS_MODUSOPERANDI_THROUGHDEBTBONDAGE;
          recordToWhichToReplicate.B_1_EVENTS_MODUSOPERANDI_GIVINGORRECEIVINGPAYMENTS = c.B_1_EVENTS_MODUSOPERANDI_GIVINGORRECEIVINGPAYMENTS;
          recordToWhichToReplicate.B_1_EVENTS_MODUSOPERANDI_CONTINUOUSCONTROLOVERTHEV = c.B_1_EVENTS_MODUSOPERANDI_CONTINUOUSCONTROLOVERTHEV;
          recordToWhichToReplicate.B_1_EVENTS_MODUSOPERANDI_AGREEMENTWITHTHEAUTHOR = c.B_1_EVENTS_MODUSOPERANDI_AGREEMENTWITHTHEAUTHOR;
          recordToWhichToReplicate.B_1_EVENTS_MODUSOPERANDI_SALEOFPERSONINTOOWNERSHIP = c.B_1_EVENTS_MODUSOPERANDI_SALEOFPERSONINTOOWNERSHIP;
          recordToWhichToReplicate.B_1_EVENTS_MODUSOPERANDI_OTHERALLFIELDSBUTTHESEALR = c.B_1_EVENTS_MODUSOPERANDI_OTHERALLFIELDSBUTTHESEALR;
          recordToWhichToReplicate.B_1_EVENTS_INDICATORSOFORGANISEDCRIM_COLLABORATIONOFMORETHANTW = c.B_1_EVENTS_INDICATORSOFORGANISEDCRIM_COLLABORATIONOFMORETHANTW;
          recordToWhichToReplicate.B_1_EVENTS_INDICATORSOFORGANISEDCRIM_EACHWITHOWNAPPOINTEDTASKS = c.B_1_EVENTS_INDICATORSOFORGANISEDCRIM_EACHWITHOWNAPPOINTEDTASKS;
          recordToWhichToReplicate.B_1_EVENTS_INDICATORSOFORGANISEDCRIM_FORAPROLONGEDORINDEFINITE
 = c.B_1_EVENTS_INDICATORSOFORGANISEDCRIM_FORAPROLONGEDORINDEFINITE;



          recordToWhichToReplicate.B_1_EVENTS_INDICATORSOFORGANISEDCRIM_USINGSOMEFORMOFDISCIPLINE = c.B_1_EVENTS_INDICATORSOFORGANISEDCRIM_USINGSOMEFORMOFDISCIPLINE;
          recordToWhichToReplicate.B_1_EVENTS_INDICATORSOFORGANISEDCRIM_SUSPECTEDOFTHECOMMISSIONO = c.B_1_EVENTS_INDICATORSOFORGANISEDCRIM_SUSPECTEDOFTHECOMMISSIONO;
          recordToWhichToReplicate.B_1_EVENTS_INDICATORSOFORGANISEDCRIM_OPERATINGONANINTERNATIONA = c.B_1_EVENTS_INDICATORSOFORGANISEDCRIM_OPERATINGONANINTERNATIONA;
          recordToWhichToReplicate.B_1_EVENTS_INDICATORSOFORGANISEDCRIM_USINGVIOLENCEOROTHERMEANS = c.B_1_EVENTS_INDICATORSOFORGANISEDCRIM_USINGVIOLENCEOROTHERMEANS;
          recordToWhichToReplicate.B_1_EVENTS_INDICATORSOFORGANISEDCRIM_USINGCOMMERCIALORBUSINESS = c.B_1_EVENTS_INDICATORSOFORGANISEDCRIM_USINGCOMMERCIALORBUSINESS;
          recordToWhichToReplicate.B_1_EVENTS_INDICATORSOFORGANISEDCRIM_ENGAGEDINMONEYLAUNDERING = c.B_1_EVENTS_INDICATORSOFORGANISEDCRIM_ENGAGEDINMONEYLAUNDERING;
          recordToWhichToReplicate.B_1_EVENTS_INDICATORSOFORGANISEDCRIM_EXERTINGINFLUENCEONPOLITI = c.B_1_EVENTS_INDICATORSOFORGANISEDCRIM_EXERTINGINFLUENCEONPOLITI;
          recordToWhichToReplicate.B_1_EVENTS_INDICATORSOFORGANISEDCRIM_DETERMINEDBYTHEPURSUITOFP = c.B_1_EVENTS_INDICATORSOFORGANISEDCRIM_DETERMINEDBYTHEPURSUITOFP;
          myMessage += recordToWhichToReplicate.ID + " - ";
        } //foreach




      } //foreach

      //try
      //{
      //  dataContext.Connection.Open();
      //  dataContext.Transaction = dataContext.Connection.BeginTransaction();
      //  dataContext.SubmitChanges(ConflictMode.ContinueOnConflict);
      //  dataContext.Transaction.Commit();
      //}
      //catch (ChangeConflictException)
      //{
      //  dataContext.Transaction.Rollback();
      //}


     
        dataContext.SubmitChanges(ConflictMode.FailOnFirstConflict);
        scope.Complete();
      }

      if (myMessage.Length > 0)
      {
        myMessage = "Entries that have been updated - " + myMessage;
      }
      else
      {
        myMessage = "No entries have updated";
      }

      System.Web.HttpContext.Current.Response.Write("<SCRIPT LANGUAGE='JavaScript'>");
      System.Web.HttpContext.Current.Response.Write("alert('" + myMessage + "')");
      System.Web.HttpContext.Current.Response.Write("</SCRIPT>");
    }



  }
}